package com.xnyzc.lhy.finance.controller.wallet;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.finance.entity.bank.OaDWithdrawalDetails;
import com.xnyzc.lhy.finance.params.dto.cashwithdrawal.OaDWithdrawalDetailsResults;
import com.xnyzc.lhy.finance.service.wallet.IOaDWalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 司机钱包表 前端控制器
 * </p>
 *
 * @author cuixiaojian
 * @since 2019-10-16
 */
@RestController
@RequestMapping("/finance/oa-dwallet")
public class OaDWalletController {

    @Autowired
    private IOaDWalletService iOaDWalletService;

    /**
     * 获取司机钱包信息
     * @return
     */
    @PostMapping("getDriverWallet")
    public Rv getDriverWallet() {
        Long driverId = TokenUtil.getTokenUserId();
        return iOaDWalletService.getDriverWalletInfo(driverId);
    }

    /**
     * 司机绑定支付宝后，保存数据
     * @return
     */
    @GetMapping ("getDriverBindAlipay")
    public Rv getDriverBindAlipay(String tokenCode){
        Long driverId = TokenUtil.getTokenUserId();
        return iOaDWalletService.getDriverBindAlipay(driverId,tokenCode);
    }
    /**
     * 获取司机的提现状态和支付宝绑定状态
     * @return
     */
    @PostMapping("getWithdrawalAndAlipayState")
    public Rv getWithdrawalAndAlipayState() {
        Long driverId = TokenUtil.getTokenUserId();
        return iOaDWalletService.getWithdrawalAndAlipayState(driverId);
    }

    /**
     * 司机的提现申请
     * @return
     */
    @PostMapping("applyDriverWithdrawal")
    public Rv applyDriverWithdrawal(@RequestBody OaDWithdrawalDetails oaDWithdrawalDetails) {
        return iOaDWalletService.applyDriverWithdrawal(oaDWithdrawalDetails);
    }

    /**
     * 获取司机申请明细
     * @return
     */
    @PostMapping("getDriverWithdrawalDetails")
    public Rv getDriverWithdrawalDetails(@RequestBody OaDWithdrawalDetailsResults param){
        return iOaDWalletService.getDriverWithdrawalDetails(param);
    }

}
